<template>
  <div>
    <template v-if="!$isWxAppIos() && !$isStore()">
      <template v-if="vipBadgeStyle == 1">
        <img class="vipStatus1 c-pz10" src="@/assets/i/wap/course/free5.png" v-if="item.payType == 1 && showAllFree"/>
        <img class="vipStatus1 c-pz10" src="@/assets/i/wap/course/svipfree5.png" v-if="svipFree" />
        <img class="vipStatus1 c-pz10" src="@/assets/i/wap/course/vipfree5.png" v-if="vipFree" />
      </template>
      <template v-else>
        <div class="vipStatus2 c-ww64 c-textAlign-c bg94CE59 c-hh28 c-lh28 c-fs18 c-fc-white radius c-pz10" v-if="item.payType == 1 && showAllFree">免费</div>
        <div class="vipStatus2 c-ww110 c-textAlign-c svipBg c-hh28 c-lh28 c-fs18 c-fc-white c-pz10" v-if="svipFree">SVIP免费</div>
        <div class="vipStatus2 c-ww96 c-textAlign-c vipBg c-hh28 c-lh28 c-fs18 c-fc-white c-pz10" v-if="vipFree">VIP免费</div>
      </template>
    </template>
  </div>
</template>
<script>
export default {
  name: "vipStatus",
  props: {
    item: {
      type: Object,
      default: () => {
        return null
      }
    },
    showAllFree: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      companyAuth: JSON.parse(localStorage.getItem("companyAuth")),
      vipBadgeStyle: localStorage.getItem("cfg") && JSON.parse(localStorage.getItem("cfg")).vipBadgeStyle ? JSON.parse(localStorage.getItem("cfg")).vipBadgeStyle : 1
    };
  },
  computed: {
    svipFree() {
      return ((this.item != null && this.item.cProdType && this.item.cProdType == 523) ||
      ((this.item != null && ((this.item.cProdType && this.item.cProdType != 523 && this.item.cProdType != 501) || (!this.item.cProdType))) && (this.item != null && this.item.payType != null && this.item.svipDiscount != null && this.item.vipDiscount != null && (Number(this.item.price) != 0 && this.item.payType == 2) && this.item.svipDiscount == 0 && this.item.vipDiscount != 0) ||
      (this.item != null && this.item.priceType != null && this.item.priceType == 3) || // 公开课列表价格类型
      (this.item != null && this.item.detailInfo != null && this.item.detailInfo.payType == 2 && Number(this.item.detailInfo.price) > 0 && this.item.detailInfo.svipDiscount == 0 && this.item.detailInfo.vipDiscount != 0) || // catDetailList中课程、专栏、知识套餐角标
      (this.item != null && this.item.prodType != null && this.item.detailInfo != null && this.item.prodType == 8 && this.item.detailInfo.permission == 20)) || // catDetailList中资料角标
      (this.item != null && this.item.prodType != null && this.item.prodType == 8 && this.item.permission == 20 && Number(this.item.svipDiscount) == 0)) || // 资料列表svip角标
      (this.item != null && this.item.prodType != null && this.item.detailInfo != null && (this.item.prodType == 12 || this.item.prodType == 7) && Number(this.item.detailInfo.price) != 0 && this.item.detailInfo.svipDiscount == 0 && this.item.detailInfo.vipDiscount != 0) // catDetailList中商城商品角标
    },
    vipFree() {
      return (this.item != null && this.item.cProdType && this.item.cProdType == 501) ||
      ((this.item != null && ((this.item.cProdType && this.item.cProdType != 523 && this.item.cProdType != 501) || (!this.item.cProdType))) && (this.item != null && this.item.payType != null && this.item.vipDiscount != null && (Number(this.item.price) != 0 && this.item.payType == 2) && this.item.vipDiscount == 0) ||
      (this.item != null && this.item.priceType != null && this.item.priceType == 2) || // 公开课列表价格类型
      (this.item != null && this.item.detailInfo != null && this.item.detailInfo.payType == 2 && Number(this.item.detailInfo.price) > 0 && this.item.detailInfo.vipDiscount == 0) || // catDetailList中课程、专栏、知识套餐角标
      (this.item != null && this.item.prodType != null && this.item.detailInfo != null && this.item.prodType == 8 && this.item.detailInfo.permission == 17)) || // catDetailList中资料角标
      (this.item != null && this.item.prodType != null && this.item.prodType == 8 && this.item.permission == 17 && Number(this.item.vipDiscount) == 0) || // 资料列表vip角标
      (this.item != null && this.item.prodType != null && this.item.detailInfo != null && (this.item.prodType == 12 || this.item.prodType == 7) && Number(this.item.detailInfo.price) != 0 && this.item.detailInfo.vipDiscount == 0) // catDetailList中商城商品角标
    }
  },
  watch: {
  },
  methods: {
  },
  created() {
  },

};
</script>

<style scoped>
.vipStatus1 {
  position: absolute;
  top: 0;
  left: 0;
  width: 1.5rem;
  height: 1.5rem;
}
.vipStatus2 {
  position: absolute;
  top: 0;
  left: 0;
}
.vipBg {
  background-image: linear-gradient(90deg, #F4CE77 0%, #D49720 96%);
  border-radius: 0 0 0.4rem 0;
}
.svipBg {
  background-image: linear-gradient(90deg, #F0B380 0%, #CD6622 95%);
  border-radius: 0 0 0.4rem 0;
}
.bg94CE59 {
  background: #94CE59;
}
.radius {
  border-radius: 0 0 0.25rem 0;
}
</style>
